package md.frolov.bible.serialization;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class SerializationTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		int c = 'а';
		
		System.out.println(c);
		
		if(true) return;
		
		SerClass st1 = new SerClass();
		SerClass st2 = new SerClass();
		System.out.println(st1.getTime());
		System.out.println(st2.getTime());
		
		try{
			FileOutputStream fos1 = new FileOutputStream("/home/gusto/Desktop/ser/dt1");
			FileOutputStream fos2 = new FileOutputStream("/home/gusto/Desktop/ser/dt2");
			ObjectOutputStream out1 = new ObjectOutputStream(fos1);
			ObjectOutputStream out2 = new ObjectOutputStream(fos2);
			out1.writeObject(st1);
			out2.writeObject(st2);
			out1.close();
			out2.close();
		} catch(IOException e){
			e.printStackTrace();
		}
		
		st1 = null;
		st2 = null;
		System.gc();
		
		try{
			FileInputStream fis1 = new FileInputStream("/home/gusto/Desktop/ser/dt1");
			FileInputStream fis2 = new FileInputStream("/home/gusto/Desktop/ser/dt2");
			ObjectInputStream in2 = new ObjectInputStream(fis1);
			ObjectInputStream in1 = new ObjectInputStream(fis2);
			st1 = (SerClass) in1.readObject();
			st2 = (SerClass) in2.readObject();
			in1.close();
			in2.close();
		} catch (IOException e){
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		
		System.out.println(st1.getTime());
		System.out.println(st2.getTime());
	}

}
